/**
 *  This file is part of AugeasWH.
 *
 *  AugeasWH. is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  AugeasWH. is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with AugeasWH.  If not, see <http://www.gnu.org/licenses/>.
 */

package cz.fit.vutbr.pis2012.augeaswh.control.administration.user;

import java.io.Serializable;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.bean.ViewScoped;

import org.richfaces.component.SortOrder;

@ManagedBean
@ViewScoped
public class UsersSortingBean implements Serializable {
	
	private static final long serialVersionUID = 9125973855028434484L;
	private SortOrder nameOrder = SortOrder.unsorted;
    private SortOrder roleOrder = SortOrder.unsorted;
    
    public void sortByName() {
        roleOrder = SortOrder.unsorted;
        if (nameOrder.equals(SortOrder.ascending)) {
            setNameOrder(SortOrder.descending);
        } else {
        	setNameOrder(SortOrder.ascending);
        }
    }
    
    public void sortByRole() {
        nameOrder = SortOrder.unsorted;
        if (roleOrder.equals(SortOrder.ascending)) {
            setRoleOrder(SortOrder.descending);
        } else {
        	setRoleOrder(SortOrder.ascending);
        }
    }

	public SortOrder getNameOrder() {
		return nameOrder;
	}

	public void setNameOrder(SortOrder nameOrder) {
		this.nameOrder = nameOrder;
	}

	public SortOrder getRoleOrder() {
		return roleOrder;
	}

	public void setRoleOrder(SortOrder roleOrder) {
		this.roleOrder = roleOrder;
	}
}
